﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data;
using System.Data.SqlClient;
using DAL.Entities;

namespace DAL.Entities_DAL
{
    public class KH_CH_DAL: BaseDAL, UTL.IBaseDAL
    {
        public int Count()
        {
            throw new NotImplementedException();
        }

        public DataTable Select()
        {
            var sql = @" select * from KH_CH";
            return ExecuteQuery(sql);
        }

        public DataTable Select(object obj)
        {
            throw new NotImplementedException();
        }

        public object GetByKey(object key)
        {
            throw new NotImplementedException();
        }

        public bool Delete(string id)
        {
            throw new NotImplementedException();
        }

        public bool Insert(object obj)
        {
            throw new NotImplementedException();
        }

        public bool Update(object obj)
        {
            throw new NotImplementedException();
        }

        public DataTable Search(string name)
        {
            throw new NotImplementedException();
        }

        //load data theo ma can ho tu table KH_CH

        public DataTable hthi(string mch)
        {
            var sql = @" 
                            select b.ma_ch, c.hoten_kh, NGAY_THUE, ngay_tra
                            from can_ho a, KH_CH b, khach_hang c
                            where a.ma_ch = b.ma_ch and b.ma_kh = c.ma_kh
                                    and a.ma_ch ='{0}'
                            
                            ";
            sql = string.Format(sql, mch);
            return ExecuteQuery(sql);
        }
    }
}
